import 'package:flutter/material.dart';
import 'package:simple_music_app/main.dart';
import 'package:simple_music_app/pages/search_page/widgets/search_result_page.dart';

class Routes {
  // 路由名称常量
  static const String home = 'home';
  static const String searchResult = 'search_res';

  // 路由生成器
  static Route<dynamic> generateRoute(RouteSettings settings) {
    switch (settings.name) {
      case home:
        return MaterialPageRoute(
          builder: (_) => const MyHomePage(),
        );
      case searchResult:
        final args = settings.arguments as String;
        return MaterialPageRoute(
          builder: (_) => SearchResultPage(keyword: args),
        );
      default:
        return MaterialPageRoute(
          builder: (_) => Scaffold(
            body: Center(
              child: Text('No route defined for ${settings.name}'),
            ),
          ),
        );
    }
  }
}
